<?php

namespace CbjCode\General;

use CbjCode\General\Providers\JsonProviders;
use Illuminate\Support\ServiceProvider;

/**
 * Class GeneralProviders
 * @package CbjCode\Providers
 */
class GeneralProviders extends ServiceProvider
{

    /**
     * 服务提供者加是否延迟加载.
     *
     * @var bool
     */
    protected $defer = true;

    /**
     * Bootstrap the application services.
     *
     * @return void
     */
    public function boot()
    {
        $configPath = base_path('vendor/cbj_code/general/src/config/response_json.php');
        if (function_exists('config_path')) {
            $publishPath = config_path('response_json.php');
        } else {
            $publishPath = base_path('config/response_json.php');
        }
        $this->publishes([$configPath => $publishPath], 'config');
    }

    /**
     * Register the application services.
     *
     * @return void
     */
    public function register()
    {
        $this->app->singleton('json', function () {
            return JsonProviders::instance();
        });
    }

    /**
     * Get the services provided by the provider.
     *
     * @return array
     */
    public function provides()
    {
        return ['json'];
    }

}
